package com.equdao.car_violation_inquiry.controller;


import com.equdao.car_violation_inquiry.pojo.ChannelManageDO;
import com.equdao.car_violation_inquiry.pojo.Result;
import com.equdao.car_violation_inquiry.service.ChannelManageService;
import com.equdao.car_violation_inquiry.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * @Author: 杨忠强
 * @Date: 2018/6/4 18:04
 * @Description:
 */
@Controller
@RequestMapping("/backstage")
public class ChannelManageController {

    @Autowired
    ChannelManageService channelManageService;

    @PostMapping("/saveChannel")
    public String saveChannel(ChannelManageDO channelManageDO) {
        Integer integer = channelManageService.saveChannel(channelManageDO);
        System.out.println("添加基本信息成功" + integer);
        return null;
    }


    @PostMapping("/updateChannel")
    public String updateChannel(ChannelManageDO channelManageDO) {

        Integer integer = channelManageService.updateChannel(channelManageDO);
        System.out.println("添加基本信息成功" + integer);

        return null;
    }

    @PostMapping("/findChannelById")
    public String findChannelById(Integer id) {

        ChannelManageDO channelById = channelManageService.findChannelById(id);
        System.out.println("查询成功" + channelById);


        return null;
    }

    /**
     * 查询下游通道列表
     * */
    @GetMapping("/findChannelList")
    public ModelAndView findChannelList(@RequestParam(value = "page",defaultValue = "0") Integer page, @RequestParam(value = "size",defaultValue = "2") Integer size, Map<String,Object> map) {
        Result result;
        List<ChannelManageDO> channelList = channelManageService.findChannelList();
        System.out.println("查询成功" + channelList);
        map.put("channelList",channelList);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username","你好啊");
        modelAndView.setViewName("list");
        return modelAndView;
    }


 }
